package com.efast.dmom.mes.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.dmom.mes.bean.QualityGroup;
import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.entity.base.IModificationFlags;
import com.efast.dmom.mes.service.QualityGroupService;

@Controller
@RequestMapping(value = "/group")
public class QualityGroupController {
	@Autowired
	private QualityGroupService qualityGroupService;
	
	@RequestMapping(value = "/groupAddOrEdit")
	public @ResponseBody ResultBean save(@RequestBody QualityGroup qualityGroup) {
		ResultBean resultBean = new ResultBean(true,' ');
		// Judge to add
		if (qualityGroup.getModificationFlag()== IModificationFlags.NEW) {
					return qualityGroupService.save(qualityGroup);
				// Judge to update
		} else if (qualityGroup.getModificationFlag() == IModificationFlags.MODIFIED) {
					return qualityGroupService.update(qualityGroup);
		}
		return resultBean;
	}
	@RequestMapping(value = "/batchDeleteById")
	public @ResponseBody ResultBean batchDeleteById(@RequestBody List<QualityGroup> list) {
		ResultBean batchDeleteById = qualityGroupService.batchDeleteById(list);
		return batchDeleteById;
	}
	// 通过id集合查询数据
	@RequestMapping(value = "/selectByIds")
	public @ResponseBody ResultBean selectByIds(@RequestBody List<QualityGroup> list) {
		ResultBean selectByIds = qualityGroupService.selectByIds(list);
		return selectByIds;
	}

}
